function [type] = check_field(control, name)
% check to see if the control structure has a field with name 'name'
% return 0 - field not found
% return 1 - field found and is a number
% return 2 - field found and is a character
% return 4 - field found and it is a STRUCT
% return -1 - field name is ambiguous within string.
% the actual name is stored in the value argument, 
% but for now we don't return it. 
%
% 10/20/99 P. Manis
%
type = 0;
value = [];
names=fieldnames(control);
nfield = size(names);
i = find(strcmp(name, names));
if(isempty(i)) % none found.
   return
end
if(size(i)>1)
   type = -1;
   return;
end
listinfo='';
% now determine the type
thisname = char(names(i));
arg = strcat('control.', thisname);
if(isstruct(eval(char(arg))))
   value = sprintf('%s', thisname); % return name of structure...
   type = 4;
end
if(isnumeric(eval(char(arg))))
   value = sprintf('%g', eval(char(arg)));
   type = 1;
end
if(ischar(eval(char(arg))))
   value = sprintf('''%s''', eval(char(arg)));
   type = 2;
end
if(isempty(eval(char(arg))))
   value = [];
   type = 0;
end



